#include "stdafx.h"
#include <fstream>
#include <string>

void count_it(int& co, int tmp)
{
	if (5 == tmp)
	{
		++co;
	}
	else if(tmp/10)
	{
		count_it(co, tmp/10);
	} 
}

TEST(atof, aa)
{
	fstream file;
	char sysInputFile[] = "jack.txt";
	file.open(sysInputFile);
	string lineBuffer;
	vector<int> count_five;
	int count_ = -1;

	while (!file.eof())
	{
		getline(file, lineBuffer);
		if (lineBuffer.length() == 0)
			continue; //ignore all empty lines
		else 
		{
			//do something here
			if (-1 == count_)
			{
				count_ = atoi(lineBuffer.c_str());
			} else if (0 == count_)
			{
				break;
			} else
			{

				int num1 = atoi(lineBuffer.c_str());
				lineBuffer.erase(0, lineBuffer.find(" ", 1));
				int num2 = atoi(lineBuffer.c_str());
				int sum_ = num1 + num2;
				int c = 0;
				count_it(c, sum_);
				if (0 == sum_%5 && 0 != sum_%10)
				{
					c++;
				}
				count_five.push_back(c);
			}
		}
	}

	vector<int>::iterator iter = count_five.begin();
	while (count_five.end() != iter)
	{
		cout<<*iter<<endl;
		++iter;
	}
}